//
//  OATabBarVC.m
//  OA项目
//
//  Created by innofive on 2018/4/12.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OATabBarVC.h"
#import "OAMainVC.h"
#import "OAAddressBookVC.h"
#import "OAMeCenterVC.h"
#import "OAChatListVC.h"
#import "OAAddressBookVC.h"
@interface OATabBarVC ()
@property(nonatomic,strong)NSMutableArray *vcs;
@end

@implementation OATabBarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSArray *titles = @[@"首页",@"通讯录",@"消息",@"个人中心"];
    NSArray *imageDes = @[@"icon_home_default",@"icon_message_default",@"icon_information_default",@"icon_mine_default"];
    NSArray *imageSels = @[@"icon_home_selected",@"icon_message_selected",@"icon_information_selected",@"icon_mine_selected"];

    OAMainVC *vc = [[OAMainVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    [self createVC:vc title:titles[0] imageName:imageDes[0]selImageName:imageSels[0]];

    
    OAAddressBookVC *vc1 = [[OAAddressBookVC alloc]init];
    [self createVC:vc1 title:titles[1] imageName:imageDes[1]selImageName:imageSels[1]];

    OAChatListVC *vc2 = [[OAChatListVC alloc]init];
    [self createVC:vc2 title:titles[2] imageName:imageDes[2]selImageName:imageSels[2]];

    OAMeCenterVC *vc3 = [[OAMeCenterVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    [self createVC:vc3 title:titles[3] imageName:imageDes[3]selImageName:imageSels[3]];

    self.viewControllers = self.vcs;

}

-(void)createVC:(UIViewController *)vc title:(NSString *)title imageName:(NSString *)imageName selImageName:(NSString *)selimageName
{
    vc.title = title;
    UINavigationController *nac = [[UINavigationController alloc]initWithRootViewController:vc];
    nac.tabBarItem.title = title;
    nac.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nac.tabBarItem.badgeValue = @"1";
    nac.tabBarItem.selectedImage =[[UIImage imageNamed:selimageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.vcs addObject:nac];
    
}


//- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
//{
//    if (tabBarController.selectedIndex==1) {
//        　if (transiting) {
//            return;
//            
//        }
//        transiting = YES;
//        [self transitionFromViewController:_currentVC toViewController:newVC duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
//            
//        } completion:^(BOOL finished) {
//            transiting = NO;
//            
//        }];
//    }
//    
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSMutableArray *)vcs
{
    if (!_vcs) {
        _vcs = [NSMutableArray array];
    }
    return _vcs;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
